package org.autumn.netty;

import cn.hutool.core.io.file.FileReader;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class TransferToTest {
    public static void main(String[] args) throws FileNotFoundException {
        // test file channel
        try (
                FileChannel form = new FileInputStream(new FileReader("netty.txt").getFile()).getChannel();
                FileChannel to = new FileOutputStream("to.txt").getChannel();
        ) {
            form.transferTo(0, form.size(), to);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
